﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DO.Domain.Repositories
{
    public abstract class RepositoryLocatorBase: IRepositoryLocator
    {

        #region IRepositoryLocator Members

        TEntity IRepositoryLocator.Save<TEntity>(TEntity instance)
        {
            return this.GetRepository<TEntity>().Save(instance);
        }

        void IRepositoryLocator.Update<TEntity>(TEntity instance)
        {
            this.GetRepository<TEntity>().Update(instance);
        }

        void IRepositoryLocator.Delete<TEntity>(TEntity instance)
        {
            this.GetRepository<TEntity>().Delete(instance);
        }

        TEntity IRepositoryLocator.GetByIdentity<TEntity>(long identity)
        {
            return this.GetRepository<TEntity>().GetByIdentity(identity);
        }

        IQueryable<TEntity> IRepositoryLocator.FindAll<TEntity>()
        {
            return this.GetRepository<TEntity>().FindAll();
        }

        public abstract IRepository<T> GetRepository<T>();

        #endregion
    }
}
